import React from 'react';
import { connect } from 'dva';
import Link from 'umi/link'
import { Table, Button } from 'antd';

import DocCreate from './DocCreate'

const linePath = '/Docs/Doc';

@connect(({ partnerOrgModel }) => ({ partnerOrgModel }))
class List extends React.Component {
  state = {
  }

  treeview = [
      {
        title: '',
        dataIndex: '_',
        render: (_, { id }) => {
          return <Link to={`${linePath}?id=${id}`}>查看</Link>;
        },
      },
      { title: '名称', dataIndex: 'name', },
  ]

  async componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'partnerOrgModel/listOrg',
      payload: {is_company: true},

    });
  }

  showForm() {
    const { dispatch } = this.props;
    dispatch({
      type: 'partnerOrgModel/show',
      payload: 'newForm'
    });
  }


  render() {
    const { partnerOrgModel: { recordsList } } = this.props;

    //console.log(recordsList)

    return (
      <div>

        <Button onClick={()=>this.showForm()}>新建</Button>
        <DocCreate />
        <Table columns={this.treeview} dataSource={recordsList} rowKey="id" />


      </div>
    );
  }
}

export default List;





